%******************************************************************
% DH1 Utilities
% Ver Date       Name       Description
% 0.1 16/07/2012 T Jelliffe Read TRAJ.ASC and plot outputs
%
%******************************************************************

% Read the data, filling A in column order
fid = fopen('../TRAJ.ASC');
A = fscanf(fid, '%g %g %g %g %g %g %g %g %g %g', [10 inf]);
fclose(fid);

% Transpose so that A matches the orientation of the file
% Do not show this step
A = A';

% Plot the columns
plotyy(A(:,1),A(:,4),A(:,1),A(:,5))

title('Altitude vs Time')

% Set the labels for height to the full number
oldylabels = get(gca,'ytick')
set(gca,'yticklabel',newylabels)

xlabel('Time (s)')
ylabel('Altitude (ft)')
grid on

% Draw a vertical line at the apogee height
[v,i] = max(A(:,8))
x1vec = A(:,1)
y1vec = A(:,8)
x1coord = x1vec(i)
line([x1coord x1coord],[0 250000],'Color','r')